var F_Habit_Entrance = {
    _init: function () {
        if (B_Login._checkUpdate(), M_HeadFoot._headShow(1), "demo" != M_Init._controller && B_User._isDemoUser())B_Login._openLogin("background"); else {
            switch (M_Init._clean(), M_Init._controller) {
                case"demo":
                    M_Init._api.innerOperationHabitUser = "demoInnerOperationHabitUser";
                    break;
                default:
                    M_Init._api.innerOperationHabitUser = "innerOperationHabitUser"
            }
            M_Init._dateCache.begin = M_Init._dateChoose.begin, M_Init._dateCache.end = M_Init._dateChoose.end, M_Common._getOrderGame("habit", "", "1-2-6"), B_Date._chooseSection({
                autoCommit: !1,
                todayValid: !1
            }, 1, M_Init._dateChoose.begin, M_Init._dateChoose.end, function (e, t) {
                e == M_Init._dateCache.begin && M_Init._dateCache.end == t || (M_Init._dateCache.begin = e, M_Init._dateCache.end = t, F_Habit_Info._getInfo())
            })
        }
    }
}, F_Habit_Info = {
    _tab: ["活跃玩家", "新增玩家", "付费玩家", "潜在付费玩家", "潜在流失玩家"],
    _init: [{
        type: "togetherTab",
        name: "平均游戏时长与次数",
        tab: ["每日", "每周", "每月"],
        tips: [{}, {position: "second", content: ["当日该类用户的人均游戏次数及时长", "当自然周该类用户的人均总游戏次数及时长", "当自然月该类用户的人均总游戏次数及时长"]}]
    }, {
        type: "togetherTab",
        name: "每周游戏频次分布",
        tab: ["周游戏天数", "周游戏次数"],
        tips: [{}, {position: "second", content: ["所选时期内，玩家在一个自然周中活跃天数的分布情况", "所选时期内，玩家在一个自然周中活跃次数的分布情况"]}]
    }, {
        type: "togetherTab",
        name: "游戏时长分布",
        tab: ["周游戏时长", "单日游戏时长", "单次游戏时长"],
        tips: [{}, {
            position: "second",
            content: ["所选时期内，玩家在一个自然周中活跃总时长的分布情况", "所选时期内，玩家在一日中活跃总时长的分布情况", "所选时期内，玩家在一日中每次玩游戏的时长分布情况"]
        }]
    }, {
        type: "together",
        name: "游戏时段分布",
        tab: [],
        tips: [{position: "first", content: "所选时期内，全天各小时段中全部玩家的分布情况"}]
    }, {type: "together", name: "活跃机型分布", tab: [], tips: [{position: "first", content: "所选时期内，全天各小时段中全部玩家的分布情况"}]}],
    _port: [[[[{name: "游戏次数", key: "user_habit_day|active|login_times"}, {
        name: "游戏时长",
        key: "user_habit_day|active|online_time"
    }], [{name: "游戏次数", key: "user_habit_day|new|login_times"}, {
        name: "游戏时长",
        key: "user_habit_day|new|online_time"
    }], [{name: "游戏次数", key: "user_habit_day|paid|login_times"}, {
        name: "游戏时长",
        key: "user_habit_day|paid|online_time"
    }], [{name: "游戏次数", key: "user_habit_day|potential_pay|login_times"}, {
        name: "游戏时长",
        key: "user_habit_day|potential_pay|online_time"
    }], [{name: "游戏次数", key: "user_habit_day|potential_lost|login_times"}, {
        name: "游戏时长",
        key: "user_habit_day|potential_lost|online_time"
    }]], [[{name: "游戏次数", key: "user_habit_week|active|login_times"}, {
        name: "游戏时长",
        key: "user_habit_week|active|online_time"
    }], [{name: "游戏次数", key: "user_habit_week|new|login_times"}, {
        name: "游戏时长",
        key: "user_habit_week|new|online_time"
    }], [{name: "游戏次数", key: "user_habit_week|paid|login_times"}, {
        name: "游戏时长",
        key: "user_habit_week|paid|online_time"
    }], [{name: "游戏次数", key: "user_habit_week|potential_pay|login_times"}, {
        name: "游戏时长",
        key: "user_habit_week|potential_pay|online_time"
    }], [{name: "游戏次数", key: "user_habit_week|potential_lost|login_times"}, {
        name: "游戏时长",
        key: "user_habit_week|potential_lost|online_time"
    }]], [[{name: "游戏次数", key: "user_habit_month|active|login_times"}, {
        name: "游戏时长",
        key: "user_habit_month|active|online_time"
    }], [{name: "游戏次数", key: "user_habit_month|new|login_times"}, {
        name: "游戏时长",
        key: "user_habit_month|new|online_time"
    }], [{name: "游戏次数", key: "user_habit_month|paid|login_times"}, {
        name: "游戏时长",
        key: "user_habit_month|paid|online_time"
    }], [{name: "游戏次数", key: "user_habit_month|potential_pay|login_times"}, {
        name: "游戏时长",
        key: "user_habit_month|potential_pay|online_time"
    }], [{name: "游戏次数", key: "user_habit_month|potential_lost|login_times"}, {
        name: "游戏时长",
        key: "user_habit_month|potential_lost|online_time"
    }]]], [[[{name: "游戏时长", key: "user_habit_freq|login_days_week|active"}], [{
        name: "游戏时长",
        key: "user_habit_freq|login_days_week|new"
    }], [{name: "游戏时长", key: "user_habit_freq|login_days_week|paid"}], [{
        name: "游戏时长",
        key: "user_habit_freq|login_days_week|potential_pay"
    }], [{name: "游戏时长", key: "user_habit_freq|login_days_week|potential_lost"}]], [[{
        name: "游戏次数",
        key: "user_habit_freq|login_times_week|active"
    }], [{name: "游戏次数", key: "user_habit_freq|login_times_week|new"}], [{
        name: "游戏次数",
        key: "user_habit_freq|login_times_week|paid"
    }], [{name: "游戏次数", key: "user_habit_freq|login_times_week|potential_pay"}], [{
        name: "游戏次数",
        key: "user_habit_freq|login_times_week|potential_lost"
    }]]], [[[{name: "游戏时长", key: "user_habit_oltime|oltime_week|active"}], [{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_week|new"
    }], [{name: "游戏时长", key: "user_habit_oltime|oltime_week|paid"}], [{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_week|potential_pay"
    }], [{name: "游戏时长", key: "user_habit_oltime|oltime_week|potential_lost"}]], [[{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_day|active"
    }], [{name: "游戏时长", key: "user_habit_oltime|oltime_day|new"}], [{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_day|paid"
    }], [{name: "游戏时长", key: "user_habit_oltime|oltime_day|potential_pay"}], [{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_day|potential_lost"
    }]], [[{name: "游戏时长", key: "user_habit_oltime|oltime_once|active"}], [{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_once|new"
    }], [{name: "游戏时长", key: "user_habit_oltime|oltime_once|paid"}], [{
        name: "游戏时长",
        key: "user_habit_oltime|oltime_once|potential_pay"
    }], [{name: "游戏时长", key: "user_habit_oltime|oltime_once|potential_lost"}]]], [[[{
        name: "活跃玩家",
        key: "user_habit_olslot|active"
    }], [{name: "新增玩家", key: "user_habit_olslot|new"}], [{
        name: "付费玩家",
        key: "user_habit_olslot|paid"
    }], [{name: "潜在付费玩家", key: "user_habit_olslot|potential_pay"}], [{
        name: "潜在流失玩家",
        key: "user_habit_olslot|potential_lost"
    }]]], [[[{name: "活跃玩家", key: "user_habit_device|active"}], [{
        name: "新增玩家",
        key: "user_habit_device|new"
    }], [{name: "付费玩家", key: "user_habit_device|paid"}], [{
        name: "潜在付费玩家",
        key: "user_habit_device|potential_pay"
    }], [{name: "潜在流失玩家", key: "user_habit_device|potential_lost"}]]]],
    _domInit: function () {
        $("#headerTop .fl").remove();
        for (var e = [], t = {}, a = 0; a < F_Habit_Info._tab.length; a++)0 == a && (t = {
            id: a,
            name: F_Habit_Info._tab[a]
        }), e.push({id: a, name: F_Habit_Info._tab[a]});
        var i = M_Inside._dropHtml("bs_drop_user_type", "选择分析对象", t, e);
        $("#headerTop").prepend(i), M_Inside._dropShow("tg-selected-drop"), M_Inside._dropSelected(function (e, t) {
            M_Init._dataCache.tabIndex = e, F_Habit_Info._formatInfo()
        }, "tg-selected-drop"), M_Inside._dropLeave("tg-selected-drop"), M_Inside._htmlChartTable($("#ct_main_area"), F_Habit_Info._init), M_Inside._downloadCsv(), F_Habit_Info._getInfo()
    },
    _getInfo: function () {
        for (var e = M_Init._dateCache.begin, t = M_Init._dateCache.end, a = [], i = 0; i < F_Habit_Info._init.length; i++)a.push("bs_chart_" + i + "_0_0");
        var _ = {};
        _.start_date = e, _.end_date = t, _.game_id = M_Init._gameId, _ = B_Common._postData(_), B_Port._ajax(M_Init._api.innerOperationHabitUser, "post", !0, _, function () {
            for (var e = 0; e < a.length; e++)$("#" + a[e]).html(B_Pre._loading())
        }, function () {
            for (var e = 0; e < a.length; e++)$("#" + a[e]).html("")
        }, function (e, t) {
            e && (M_Init._dataCache.tabIndex = 0, M_Init._dataCache.data = e, F_Habit_Info._formatInfo())
        }, function (e, t, i) {
            for (var _ = 0; _ < a.length; _++)$("#" + a[_]).html(B_Pre._empty(t))
        })
    },
    _formatInfo: function () {
        for (var e = 0; e < F_Habit_Info._init.length; e++)if (M_Init._dataCache["position_" + e] || (M_Init._dataCache["position_" + e] = 0), F_Habit_Info._init[e].tab.length > 0) {
            for (var t = 0; t < F_Habit_Info._init[e].tab.length; t++)if (M_Init._dataCache["position_" + e] == t) {
                F_Habit_Info._chartHtml(e, t), M_Inside._chartTableIcon(F_Habit_Info._init[e].type, e, t);
                break
            }
            M_Inside._tabChangePerChart(e, F_Habit_Info._init[e].type, "habit")
        } else F_Habit_Info._chartHtml(e, 0), M_Inside._chartTableIcon(F_Habit_Info._init[e].type, e, 0)
    },
    _chartHtml: function (e, t) {
        M_Init._dataCache.tabIndex || (M_Init._dataCache.tabIndex = 0), M_Init._dataCache["position_" + e] = t;
        var a = M_Init._dataCache.data, i = {x_axis: [], y_axis: [], yFormat: ""}, _ = {}, n = 50, o = "", s = "";
        switch (e + "") {
            case"0":
                i.xFormatDate = !0, i.yDouble = !0, i.yDoubleLabel = ["次", "mins"], i.tooltip = {
                    type: "diff",
                    num: 2,
                    unit: ["次", "mins"]
                };
                break;
            case"1":
            case"2":
            case"3":
            case"4":
                i.tooltip = {type: "simple", num: 1, unit: "人"}
        }
        switch (e + "") {
            case"1":
                switch (t + "") {
                    case"0":
                        _ = {head: ["游戏天数", "玩家数量(人)", "玩家占比"], body: []};
                        break;
                    default:
                        _ = {head: ["游戏频次", "玩家数量(人)", "玩家占比"], body: []}
                }
                break;
            case"2":
                _ = {head: ["游戏时长", "玩家数量(人)", "玩家占比"], body: []};
                break;
            case"3":
                _ = {head: ["游戏时段分布", "玩家数量(人)", "玩家占比"], body: []};
                break;
            case"4":
                _ = {head: ["机型", "玩家数量(人)", "玩家占比"], body: []};
                break;
            default:
                _ = {head: ["日期", "游戏次数(次)", "游戏时长(mins)"], body: []}
        }
        o = F_Habit_Info._port[e][t][M_Init._dataCache.tabIndex];
        for (var r = 0; r < o.length; r++) {
            var m = o[r].key.split("|");
            switch (e + "") {
                case"0":
                    if (a[m[0]] && a[m[0]][m[1]] && a[m[0]][m[1]][m[2]]) {
                        var l = a[m[0]][m[1]][m[2]], d = a[m[0]];
                        i.x_axis = d.x_axis;
                        for (var h = 0; h < l.length; h++)_.body[h] || (_.body[h] = [d.x_axis[h]]), _.body[h].push(l[h]);
                        0 == r ? i.y_axis.push({type: "bar", name: o[r].name, data: l}) : i.y_axis.push({
                            type: "line",
                            name: o[r].name,
                            data: l
                        })
                    }
                    break;
                case"1":
                case"2":
                    if (n = 20, a[m[0]] && a[m[0]][m[1]] && a[m[0]][m[1]][m[2]]) {
                        for (var l = a[m[0]][m[1]][m[2]], d = a[m[0]][m[1]], b = 0; b < d.distri_classify.length; b++)d.distri_classify[b] = d.distri_classify[b].replace("&gt;", ">"), d.distri_classify[b] = d.distri_classify[b].replace("&lt;", "<");
                        if (1 == e && 0 == t) {
                            for (var y = [], p = 0; p < d.distri_classify.length; p++)y[p] = d.distri_classify[p] + "天";
                            i.x_axis = y, s = "天"
                        } else i.x_axis = d.distri_classify;
                        for (var h = 0; h < l.user_num.length; h++)_.body[h] || (_.body[h] = [d.distri_classify[h] + s]), _.body[h].push(l.user_num[h]), _.body[h].push(l.user_rate[h] + "%");
                        i.y_axis.push({name: o[r].name, data: l.user_num})
                    }
                    break;
                default:
                    if (n = 4 == e ? 20 : 40, a[m[0]] && a[m[0]][m[1]]) {
                        var l = a[m[0]][m[1]];
                        i.x_axis = l.distri_classify;
                        for (var h = 0; h < l.y_axis.user_num.length; h++)_.body[h] || (_.body[h] = [l.distri_classify[h]]), _.body[h].push(l.y_axis.user_num[h]), _.body[h].push(l.y_axis.user_rate[h] + "%");
                        i.y_axis.push({name: o[r].name, data: l.y_axis.user_num})
                    }
            }
        }
        _.name = M_Inside._tableName(F_Habit_Info._init, e, t, M_Init._dateCache.begin, M_Init._dateCache.end), t = 0, M_Init._dataCache[e + "_" + t] = _, M_Inside_Chart._chartData(n, "bs_chart_" + e + "_" + t, i), M_Inside._tableHtml(1, e + "_" + t)
    }
};